//
//  GQHContractModel.m
//  Xanthium
//
//  Created by GuanQinghao on 23/03/2018.
//  Copyright © 2018 GuanQinghao. All rights reserved.
//

#import "GQHContractModel.h"


@implementation GQHContractModel

+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
    
    return @{
             @"qh_contractID" : @"id",
             @"qh_contractTime" : @"agreementTime",
             @"qh_contractState" : @"agreementState",
             @"qh_contractAdditionalContent" : @"addContent",
             @"qh_contractContent" : @"agreementText",
             @"qh_contractExpenseModel" : @"aaAgreementJson",
             @"qh_contractOtherExpenseNote" : @"otherExpensesNote",
             @"qh_contractAmount" : @"amount",
             
             @"qh_freightID" : @"sourcesInfoId",
             @"qh_qutationID" : @"quotationId",
             @"qh_ownerAvatar" : @"ownerPicture",
             @"qh_ownerName" : @"ownerName",
             @"qh_freightWeight" : @"demandVehicle",
             @"qh_freightVolume" : @"goodsVolume",
             @"qh_freightNumber" : @"goodsNum",
             @"qh_departureID" : @"origin",
             @"qh_departure" : @"origin",
             @"qh_destinationID" : @"destination",
             @"qh_destination" : @"destination",
             @"qh_mileage" : @"goodsVolume",/// 估算里程
             
             @"qh_freightName" : @"commodityName",
             @"qh_freightType" : @"demandModels",
             @"qh_freightTypeCode" : @"demandModels",
             @"qh_modelWanted" : @"demandModels",
             @"qh_lengthWanted" : @"demandVehicleLength",
             @"qh_freightUnitPrice" : @"freightUnitPrice",
             @"qh_businessTypeCode" : @"businesstypecode",
             @"qh_transportTypeCode" : @"transporttype",
             @"qh_loadingTime" : @"loadingDate",
             @"qh_consignee" : @"consignee",
             @"qh_consigneeMobile" : @"consigneePhone",
             @"qh_consigningTime" : @"goodsTime",
             
             @"qh_driverID" : @"driverInfo",
             @"qh_driverAvatar" : @"driverPicture",
             @"qh_driverName" : @"driverName",
             @"qh_driverMobile" : @"licPlateNum",
             @"qh_licensePlateNumber" : @"licPlateNum",
             @"qh_modelCode" : @"vehicleclassificationcode",
             @"qh_model" : @"vehicleclassificationcode",
             @"qh_normalLength" : @"carLength",
             @"qh_normalLoading" : @"carLoad"
             };
}

+ (nullable NSDictionary<NSString *, id> *)modelContainerPropertyGenericClass {
    
    return @{
             @"qh_contractExpenseModel" : GQHContractExpenseModel.class
             };
}

///  查看货源协议
+ (void)qh_fetchContractWithParameters:(NSDictionary *)parameters success:(void(^)(BOOL status, NSNumber *code, NSString *message, GQHContractModel *contract))success failure:(void(^)(NSError *error))failure {
    
    NSString *APIURLString = [[NSString qh_APIURLString] stringByAppendingPathComponent:@"/buWaybillAgreement/1/findOne"];
    
    [GQHNetHelper qh_requestGET:APIURLString parameters:parameters success:^(NSNumber *code, NSString *message, NSDictionary *data) {
        DLog(@"%@---%@---%@",code,message,data);
        
        if (0 == [code integerValue]) {
            
            GQHContractModel *contractModel = [GQHContractModel yy_modelWithDictionary:data];
            success(YES,code,message,contractModel);
        } else {
            
            success(NO,code,message,nil);
        }
    } failure:^(NSError *error) {
        
        failure(error);
    }];
}

@end
